<!--
/// 
/// MaDAson - Toolkit for Model Driven Software Development
///
/// Copyright [2006] Marcus Lankenau
/// 
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///  
///     http://www.apache.org/licenses/LICENSE-2.0
///  
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// 
-->
<%@ Page Language="C#" %>
<%@ Import Namespace="Madason.MetaModel" %>
<%@ Import Namespace="Madason.MetaModel.DAO" %>
package <%= Class.Namespace.FullName %>;

import java.util.*;
import java.lang.reflect.Constructor;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * <%= Class.Documentation.Replace("\n", "\n	* ") %>
 */
public abstract class <%= Class.Name + "Access" %>
{   
    public static <%= Class.Name %>Access getInstance()
	{
		String implName = System.getProperty("madason.dao.impl");
		if (implName == null)
			return new <%= Class.Name %>AccessOracle();
		else
		{
			try
			{
				ClassLoader classLoader = <%= Class.Name %>Access.class.getClassLoader();
				Class cls = classLoader.loadClass("<%= Class.ExplicitName %>Access" + implName);
				Constructor ctor = cls.getConstructor(new Class[] {});
				return (<%= Class.Name %>Access) ctor.newInstance(new Object[] {});
			}
			catch (Exception e)
			{
				e.printStackTrace();
				return null;
			}
		}
	}

<% foreach (Procedure proc in Class.GetProceduresWithOutParameter()) {  %>


	/**
	 * Result-Structure for Procedure <%= proc.Name %>
	 */
	public static class <%= proc.ReturnTypeName %> implements java.io.Serializable
	{
<% foreach(Parameter param in proc.Parameters) { %>		
<%   if (param.Dir == ParameterDir.Out) { %>
		protected <%= param.Type.ExplicitName %> <%= param.Name %>;
<%   } %>
<% } %>
<% foreach(Parameter param in proc.Parameters) { %>		
<%   if (param.Dir == ParameterDir.Out) { %>
		
		public <%= param.Type.ExplicitName %> get<%= param.NamePascalCase %>()
		{
			return <%= param.Name %>;
		}
		public void set<%= param.NamePascalCase %>(<%= param.Type.ExplicitName %> <%= param.Name %>)
		{
			this.<%= param.Name %> = <%= param.Name %>;
		}
<%   } %>
<% } %>
	}
<% } %>

<% foreach (Procedure proc in Class.GetProcedures()) { %>


	/**
	 * <%= proc.Name %>
	 */
	public abstract <%= proc.ReturnTypeName %> <%= proc.Name %>(Connection conn<%= proc.ParameterString == "" ? "" : ", " %><%= proc.ParameterString %>) throws SQLException;
<% } %>
}

<script runat="server">
	private ProcedureContainer @class;

	
	public ProcedureContainer Class
	{
		get { return @class; }
		set { @class = value; }
	}

	protected string FinderParamSep(Finder finder)	
	{
		return finder.Parameters.Count > 0 ? ", " : "";
	}
</script>
